﻿@{
    ViewBag.Title = "FormSubmit";
    Layout = "~/Views/Shared/_Page.cshtml";
}


<h2>Form Submit</h2>

<div ng-app>
    <form ng-submit="requestFunding()" ng-controller="StartUpController">
        Starting: <input ng-change="computeNeeded()" ng-model="startingEstimate">
        Recommendation: {{needed}}
        <button>Fund my startup!</button>
        <button ng-click="reset()">Reset</button>
    </form>
</div>

<script type="text/javascript">
    function StartUpController($scope) {
        $scope.computeNeeded = function() {
            $scope.needed = $scope.startingEstimate * 10;
        };

        $scope.requestFunding = function() {
            window.alert("Sorry, please get more customers first.");
        };

        $scope.reset = function() {
            $scope.startingEstimate = 0;
        };
    }
</script>